
 ####################################################################
 ## INCENTIVIZING ANTICORRUPTION REFORM  - MAIN REPLICATION FILES  ##
 ###################################################################

 ## Last modified: NOV, 2024

 # Clean
 rm(list=ls())

 # Set directory
 setwd("")

 # Packages
 library(ggplot2)
 library(dplyr)
 library(ggpubr)
 library(did)
 library(doBy)
 library(stargazer)
 library(MASS)
 library(pscl)
 library(boot)
 library(reshape2)
 library(stringr)
 library(marginaleffects)
 library(readxl)
 

 ################################################ 1) MULTIPLE PERIODS DID
 
 
 ############ MULTIPLE PERIODS DID
 
 leg_did <- readRDS(file = "leg_DID.rds")

 
 
 ##### TABLE 1 (Overall and Group estimates of the effect of reelection on SNA sponsorship)
 
 
 t1 <- att_gt(yname = "sna_related",
               tname = "time_var",
               gname = "treat_g",
               idname = "legislator_ID",
               xformla = NULL,
               allow_unbalanced_panel = TRUE,
               data = leg_did,
               est_method = "reg", 
               panel = FALSE,
               clustervars = c("treat_clustvar"), 
               bstrap = FALSE,
               control_group = c("notyettreated"))
 
 ## Overall effect
 agg.simple <- aggte(t1, type = "simple")
 summary(agg.simple)
 
 ## Group estimates
 agg.gs <- aggte(t1, type = "group")
 summary(agg.gs)
 ggdid(agg.gs) + theme_light() 
 
 
 
 
 ##### FIGURE 3 (Dynamic treatment effects)
 
 agg.es <- aggte(t1, type = "dynamic")
 summary(agg.es)
 ggdid(agg.es) + theme_light() + ylab("SNA related bills") + xlab("Time period") + ggtitle("")
 

 

 
 
 

  
 ################################################ 2) FIXED EFFECTS MODELS
 
 ## TABLE 2:
 
 ## Outcomes: ACIs and SNA
 
 # 1-2) State and year FE (no controls)
 
 # 3-4) State and year FE (controls)

 # 5-6) Reelection X SMD and state and year  FE (controls)

 # 7-8) SNA Reelection X Governor's coalition and state and year  FE (controls)

 
 library(pscl)
 
 # Outcomes: ACI and SNA
 # Specifications: state and year FE
 
 # 1) SNA state and period FE (no controls)
 mod1 <- lm(sna_related ~ reelection + factor(state) + factor(year), data = leg_did)
 
 # State CSE
 summary(mod1, cluster = c("state"))
 mod_1_se <- summary(mod1, cluster = c("state"))$coefficients[,"Std. Error"]
 
 
 # 2) ACI state and period FE (no controls)
 mod2 <- lm(acl_total ~ reelection + factor(state) + factor(year), data = leg_did)
 
 # State CSE
 summary(mod2, cluster = c("state"))
 mod_2_se <- summary(mod2, cluster = c("state"))$coefficients[,"Std. Error"]
 
  
 # 3) SNA state and period FE (controls)
 mod3 <- lm(sna_related ~ reelection + gov_coal + pres_coal + margin_victory + 
                         pop_log + per_rural + corr_perception +  l_dep_budget + 
                         factor(state) + factor(year), data = leg_did)
 
 # State CSE
 summary(mod3, cluster = c("state"))
 mod_3_se <- summary(mod3, cluster = c("state"))$coefficients[,"Std. Error"]
 
 
 # 4) ACI state and period FE (controls)
 mod4 <- lm(acl_total ~ reelection + gov_coal + pres_coal + margin_victory + 
              pop_log + per_rural + corr_perception + l_dep_budget + 
              factor(state) + factor(year), data = leg_did)
 
 # State CSE
 summary(mod4, cluster = c("state"))
 mod_4_se <- summary(mod4, cluster = c("state"))$coefficients[,"Std. Error"]
 
 
 ### INTERACTION REELEC X DISTRICT TYPE
 leg_did$smd <- NA
 leg_did$smd[leg_did$district_type=="SMD"] <- 1
 leg_did$smd[leg_did$district_type=="PR"] <- 0
 table(leg_did$district_type, leg_did$smd, exclude = NULL)
 
 # 5) SNA INTERACTION REELEC X DISTRICT TYPE
 mod5 <- lm(sna_related ~ reelection*smd + gov_coal + pres_coal + margin_victory + 
              pop_log + per_rural + corr_perception +  l_dep_budget + 
              factor(state) + factor(year), data = leg_did)
 
 # State CSE
 summary(mod5, cluster = c("state"))
 mod_5_se <- summary(mod5, cluster = c("state"))$coefficients[,"Std. Error"]
 
 
 # 6) ACI INTERACTION REELEC X DISTRICT TYPE
 mod6 <- lm(acl_total ~ reelection*smd + gov_coal + pres_coal + margin_victory + 
              pop_log + per_rural + corr_perception +  l_dep_budget + 
              factor(state) + factor(year), data = leg_did)
 
 # State CSE
 summary(mod6, cluster = c("state"))
 mod_6_se <- summary(mod6, cluster = c("state"))$coefficients[,"Std. Error"]
 
 
 
 ## INTERACTION REELEC X DISTRICT TYPE
 
 # 7) SNA INTERACTION REELEC X GOVS
 mod7 <- lm(sna_related ~ reelection*gov_coal + pres_coal + margin_victory + 
              pop_log + per_rural + corr_perception +  l_dep_budget + 
              factor(state) + factor(year), data = leg_did)
 
 # State CSE
 summary(mod7, cluster = c("state"))
 mod_7_se <- summary(mod7, cluster = c("state"))$coefficients[,"Std. Error"]
 
 
 # 8) ACI INTERACTION REELEC X GOVS
 mod8 <- lm(acl_total ~ reelection*gov_coal + pres_coal + margin_victory + 
              pop_log + per_rural + corr_perception +  l_dep_budget + 
              factor(state) + factor(year), data = leg_did)
 
 # State CSE
 summary(mod8, cluster = c("state"))
 mod_8_se <- summary(mod8, cluster = c("state"))$coefficients[,"Std. Error"]
 
 

 ## Table
 stargazer(mod1, mod2, mod3, mod4, mod5, mod6, mod7 , mod8 ,
           title="Reelection and anticorruption bill sponsorship",
           se = list(mod_1_se, mod_2_se, mod_3_se, mod_4_se, 
                     mod_5_se, mod_6_se, mod_7_se, mod_8_se),
           align=TRUE, digits = 2, 
           digits.extra = 0, 
           dep.var.labels=c("ACI", "SNA"),
           covariate.labels=c("Reelection incentives"))
 
 
 
 
 
 

 
 
 
 
 
 

 
 
 
 
 
 
 
 
